#include "authorstats.h"
#include <QDebug>
#include <QString>
AuthorStats::AuthorStats(QString name, int commitNumber)
{
	this->name = name;
	this->avgAddedLine = 0;
	this->avgCommentSize = 0;
	this->avgCommitFreq = 0;
	this->avgRemovedLine = 0;
	this->maxAddedLine = 0;
	this->maxCommentSize = 0;
	this->maxCommitFreq = 0;
	this->maxRemovedLine = 0;
	this->minAddedLine = INT_MAX;
	this->minCommentSize = INT_MAX;
	this->minCommitFreq = INT_MAX;
	this->minRemovedLine = INT_MAX;
	this->commitNumber = commitNumber;
	this->lineAdded = 0;
	this->lineRemoved = 0;
}

void AuthorStats::displayInfo(void) {
	qDebug() <<  "**** Information for user " << name << " ****";
	qDebug() << " > commit number = " << commitNumber;
	qDebug() << " > comment size (avg/min/max) = " << this->avgCommentSize << " / " << this->minCommentSize << " / " << this->maxCommentSize;
	qDebug() << " > commit frequency (avg/min/max) = " << convertIntToTime(this->avgCommitFreq) << " / " << convertIntToTime(this->minCommitFreq) << " / " << convertIntToTime(this->maxCommitFreq);
	qDebug() << " > Added Lines (avg/min/max) = " << this->avgAddedLine << " / " << this->minAddedLine << " / " << this->maxAddedLine;
	qDebug() << " > Removed Lines (avg/min/max) = " << this->avgRemovedLine << " / " << this->minRemovedLine << " / " << this->maxRemovedLine;
	qDebug() << " > TotalLines (added/removed/current) = " << this->lineAdded<< " / " << this->lineRemoved<< " / " << this->lineAdded - lineRemoved;
}

QString AuthorStats::convertIntToTime(int time) {
	return QString::number(time/3600) + ":" + QString::number(time%3600/60) + ":" + QString::number(time%60);
}
